<template>
  <el-dialog
    v-el-drag-dialog
    title="优惠金额"
    :visible.sync="visible"
    width="600px"
    @close="reset"
  >
    <lb-table
      ref="lbTable"
      border
      highlight-current-row
      element-loading-text="加载中"
      :column="tableData.column"
      :data="tableData.data"
      :immediate-fetch="false"
      show-summary
      @fetch="fetchData"
    />
  </el-dialog>
</template>

<script>
  import { queryOrderManageSpeciesAmountList } from '@/api'

  export default {
    name: 'species-amount',
    data() {
      return {
        visible: false,
        tableData: {
          total: 0,
          column: [
            {
              prop: '',
              width: 100,
              label: '优惠项目',
              render: (h, { row }) => <span>平台券</span>
            },
            {
              prop: 'recordName',
              label: '优惠券名称'
            },
            {
              prop: 'payFee',
              label: '金额',
              width: 100
            }
          ],
          data: []
        }
      }
    },
    methods: {
      async open(temp) {
        this.fetchData(temp)
        return new Promise(resolve => {
          this.resolve = resolve
          this.visible = true
        })
      },
      async fetchData(temp) {
        const query = {
          orderCode: temp.orderCode
        }
        const res = await queryOrderManageSpeciesAmountList(query)
        this.tableData.data = res.data.couponDetailList
      },
      reset() {

      }
    }
  }
</script>

<style scoped>

</style>
